home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / netBoot / sun3.md / map.s < prev    next >
Encoding:
Text File  |  1990-08-14  |  3.1 KB  |  96 lines

  1. |     map.s 1.2 88/02/08 Copyright (c) 1985 by Sun Microsystems, Inc.
  2. |
  3. | /*
  4. |  * Memory Mapping and Paging on the Sun 3
  5. |  */
  6. | /*
  7. |  * Mapping registers are accessed thru the  movs  instruction in the Sun-3.
  8. |  *
  9. |  * The following subroutines accept any address in the mappable range
  10. |  * (256 megs).  They access the map for the current context register.  They
  11. |  * assume that currently we are running in supervisor state.
  12. |  */ 
  13. /* 
  14.  * These constants are fixed by the hardware, 
  15.  * so don't feel too bad that I redefined them here
  16.  */
  17. #define    FC_MAP        3        /* space for MMU ops */
  18. #define    NUMPMEGS    256        /* number of Pmegs */
  19. #define    PMAPOFF        0x10000000    /* offset for page map */
  20. #define    SMAPOFF        0x20000000    /* offset for segment map */
  21. #define    MAPADDRMASK    0x0FFFE000    /* translatable bits */
  22. #define    PME_INVALID    0        /* invalid page */
  23.  
  24.     .text
  25.  
  26.     .globl    _setpgmap
  27. _setpgmap:
  28.     movl    sp@(4),d0    | Get access address
  29.     andl    #MAPADDRMASK,d0    | Mask out irrelevant bits
  30.     addl    #PMAPOFF,d0    | Offset to page maps
  31.     movl    d0,a0
  32.     lea    FC_MAP,a1    | Get function code in a reg
  33. | The following code can be used to verify that the only page
  34. | table entries written to the Invalid Pmeg are invalid pages, since the 
  35. | consequences of writing valid entries here are somewhat spectacular.
  36.     movc    sfc,d0        | Save source function code
  37.     movc    a1,sfc        | Set source function code, too.
  38.     addl    #SMAPOFF-PMAPOFF,a0    | Offset to segment map
  39.     movsb    a0@,d1        | Get segment map entry number
  40.     subl    #SMAPOFF-PMAPOFF,a0    | Offset back to page map
  41.     movc    d0,sfc        | Restore source function code
  42. | If debug code is removed, next line must remain!
  43.     movl    sp@(8),d0    | Get page map entry to write
  44. | More debug code
  45. #if NUMPMEGS != 256
  46.     andb    #NUMPMEGS-1,d1    | Top bit ignored in 128-pmeg version
  47. #endif
  48.     cmpb    #NUMPMEGS-1,d1    | Are we writing in the Invalid Pmeg?
  49.     jne    good        | Nope, go on.
  50.     cmpl    #PME_INVALID,d0    | Writing the Invalid Page Map Entry?
  51.     jeq    good        | Yes, it's ok.
  52.     bras    .-1        | Fault out, this is nasty thing to do.
  53. good:
  54.     movc    dfc,d1        | Save dest function code
  55.     movc    a1,dfc        | Set destination function code
  56.     movsl    d0,a0@        | Write page map entry
  57.     movc    d1,dfc        | Restore dest function code
  58.     rts            | done
  59.  
  60. |
  61. | Read the page map entry for the given address v
  62. | and return it in a form suitable for software use.
  63. |
  64. | long
  65. | getpgmap(v)
  66. | caddr_t v;
  67.     .globl    _getpgmap
  68. _getpgmap:
  69.     movl    sp@(4),d0        | get access address
  70.     andl    #MAPADDRMASK,d0        | clear extraneous bits
  71.     orl    #PMAPOFF,d0        | set to page map base offset
  72.     lea    FC_MAP,a1        | Get function code in a reg
  73.     movc    sfc,d1            | Save source function code
  74.     movc    a1,sfc            | Set source function code, too.
  75.     movl    d0,a0
  76.     movsl    a0@,d0            | read page map entry
  77.                     | no mods needed to make pte from pme
  78.     movc    d1,sfc            | restore function code
  79.     rts                | done
  80.  
  81.     .globl    _setsegmap
  82. _setsegmap:
  83.     movl    sp@(4),d0    | Get access address
  84.     andl    #MAPADDRMASK,d0    | Mask out irrelevant bits
  85.     addl    #SMAPOFF,d0    | Bump to segment map offset
  86.     movl    d0,a0
  87.     movl    sp@(8),d0    | Get seg map entry to write
  88.     movc    dfc,d1        | Save dest function code
  89.     lea    FC_MAP,a1    | Get function code in a reg
  90.     movc    a1,dfc        | Set destination function code
  91.     movsb    d0,a0@        | Write segment map entry
  92.     movc    d1,dfc        | Restore dest function code
  93.     rts            | done
  94.